﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Arizu.Repository;

namespace AiRiZu
{
    public partial class Default : System.Web.UI.Page
    {
        public string[] RoomTitle = new string[14];
        public string[] Adressdesc = new string[14];
        public string[] Area = new string[14];
        public string[] JiaGe = new string[14];
        //public string[] Image = new string[14];
        public string[] imgurl = new string[14];
        public string[] sendroomid = new string[14];

        public string[] TeSeRoomTitle = new string[12];
        //public string[] Adressdesc = new string[12];
        public string[] TeSeArea = new string[12];
        public string[] RecommendedReason = new string[12];
        //public string[] Image = new string[14];
        public string[] TeSeimgurl = new string[12];
        public string[] TeSesendroomid = new string[12];

        public string[] EvRoomTitle=new string[6];
        public string[] EvaluationContent = new string[6];
        public string[] EvImage = new string[6];
        public string[] EvSendRoomid = new string[6];
        public string[] EvImageurl = new string[6];
        public string[] EvName = new string[6];

        Arizu.Entity.ImgSendRoom list = new Arizu.Entity.ImgSendRoom();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetSendRoomInfo("北京");
                GetSendRoomByTeSeInfo();
                GetEvaluationRoom();
            }
        }

        /// <summary>
        /// 绑定特价房间
        /// </summary>
        protected void GetSendRoomInfo(string adress)
        {
            DataTable dt = new DataTable();
            dt = Main.CreateInstance().GetSendRoom(adress);
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    RoomTitle[i] = dt.Rows[i]["RoomTitle"].ToString();
                    Adressdesc[i] = dt.Rows[i]["Adressdesc"].ToString();
                    Area[i] = dt.Rows[i]["Area"].ToString();
                    JiaGe[i] = dt.Rows[i]["JiaGe"].ToString();
                    sendroomid[i] = dt.Rows[i]["SendRoomid"].ToString();
                    list = Main.CreateInstance().GetImg(int.Parse(sendroomid[i]));
                    //Image[i] = list.Image;
                    imgurl[i] = "Roomimg/" + list.Image0;
                }
            }
        }
        /// <summary>
        /// 绑定特色房间
        /// </summary>
        protected void GetSendRoomByTeSeInfo()
        {
            DataTable dt = new DataTable();
            dt = Main.CreateInstance().GetSendRoomByTeSe();
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    TeSeRoomTitle[i] = dt.Rows[i]["RoomTitle"].ToString();
                    //Adressdesc[i] = dt.Rows[i]["Adressdesc"].ToString();
                    TeSeArea[i] = dt.Rows[i]["Area"].ToString();
                    RecommendedReason[i] = dt.Rows[i]["RecommendedReason"].ToString();
                    TeSesendroomid[i] = dt.Rows[i]["SendRoomid"].ToString();
                    list = Main.CreateInstance().GetImg(int.Parse(TeSesendroomid[i]));
                    //Image[i] = list.Image;
                    TeSeimgurl[i] = "Roomimg/" + list.Image0;
                }
            }
        }

        /// <summary>
        /// 绑定评价房间
        /// </summary>
        protected void GetEvaluationRoom()
        {
            DataTable dt = new DataTable();
            dt = Main.CreateInstance().GetEvaluationRoom();
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    EvSendRoomid[i] = dt.Rows[i]["SendRoomid"].ToString();
                    EvImage[i] = dt.Rows[i]["Image"].ToString();
                    EvRoomTitle[i] = dt.Rows[i]["RoomTitle"].ToString();
                    EvaluationContent[i] = dt.Rows[i]["EvaluationContent"].ToString();
                    EvImageurl[i] = "imgs/" + EvImage[i];
                    EvName[i] = dt.Rows[i]["Xing"].ToString() + dt.Rows[i]["Ming"].ToString();
                }
            }
        }

        protected void Search_Click(object sender, EventArgs e)
        {
            string checkIn = "";
            string checkOut = "";
            string searchCityValue = Request.Params["searchCityValue"].ToString();
            checkIn = Request.Params["ruzhudatevalue"].ToString();
            checkOut = Request.Params["ruzhudate1value"].ToString();
            Session["searchCityValue"] = searchCityValue;
            Session["checkIn"] = checkIn;
            Session["checkOut"] = checkOut;

            Response.Redirect("RoomList.aspx?searchCityValue=" + searchCityValue);
        }

        
        protected void Unnamed2_Command(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "select")
            {
                string city = "";
                city = GetCity(e.CommandArgument.ToString());
                GetSendRoomInfo(city);
                GetSendRoomByTeSeInfo();
                GetEvaluationRoom();
            }
        }

        protected string GetCity(string city)
        {
            string str = "";
            if (city == "bj")
            {
                str = "北京";
            }
            if (city == "sh")
            {
                str = "上海";
            }
            if (city == "nj")
            {
                str = "南京市";
            }
            if (city == "xa")
            {
                str = "西安市";
            }
            if (city == "jl")
            {
                str = "吉林市";
            }
            return str;
        }
    }
}
